#===istalismanplugin===
# -*- coding: utf-8 -*-

# $Revision: 54 $
# $Author: rchiganov@gmail.com $
# $Date: 2013-08-05 07:16:38 +0000 (Mon, 05 Aug 2013) $

#---------------------------------------------------------------------------------------------------

def autoaway_state ( pgch ):
	if not 'autoaway' in GCHCFGS[pgch]:
		GCHCFGS[pgch]['autoaway'] = 1
	if GCHCFGS[pgch]['autoaway']:
		LAST['gch'][pgch]['autoaway'] = 0
		LAST['gch'][pgch]['thr'] = None

#---------------------------------------------------------------------------------------------------

def status_default ( pgch ):
	if isinstance(GCHCFGS[pgch].get('status'), str):
		GCHCFGS[pgch]['status'] = {'status': u'Напишите "помощь" и следуйте указаниям, чтобы понять, как со мной работать', 'show': u''}
	elif not isinstance(GCHCFGS[pgch].get('status'), dict):
		GCHCFGS[pgch]['status'] = {'status': u'Напишите "помощь" и следуйте указаниям, чтобы понять, как со мной работать', 'show': u''}

#---------------------------------------------------------------------------------------------------

def access_levels():
	global GLOBACCESS
	global ACCBYCONFFILE
	vika_check_file(GLOBACCESS_FILE, '{}')
	GLOBACCESS = eval(read_file(GLOBACCESS_FILE))
	for jid in ADMINS:
		GLOBACCESS[jid] = 100
		write_file(GLOBACCESS_FILE, str(GLOBACCESS))
	vika_check_file(ACCBYCONF_FILE, '{}')
	ACCBYCONFFILE = eval(read_file(ACCBYCONF_FILE))

#---------------------------------------------------------------------------------------------------

register_stage1_init(autoaway_state)
register_stage1_init(status_default)
register_stage0_init(access_levels)

#---------------------------------------------------------------------------------------------------
